

$(function(){

    /*初始化编辑器，展现方式为弹窗*/

    $.fn.editable.defaults.mode = 'placement';
    window.ajaxData = {};
    $('.edit_price').editable({
        type: 'text',
        pk: 1,
        url: "/Admin/Ad/priceSettingApi.html",
        title: '编辑价格',
        placement:'right',
        validate:function(value){
            /*组装数据*/
            if($.trim(value) == '') return '不能为空！';
            else if(parseInt($.trim(value)) < 0)
            {
                return '请输入大于或等于0 的数！';
            }
            else if(isNaN($.trim(value)))
            {
                return '请输入数字！';
            }
            ajaxData.position_id = $(this).closest('.banner_list').attr('data-id');
            ajaxData.code = $(this).attr('data-code');
            ajaxData.code_value = value;
        },
        ajaxOptions: {
            type: 'post',
            dataType: 'json',
            data:ajaxData,
            beforeSend:function(){
            }
        },
        success: function(response, newValue) {
            if(response.result === true)
            {

            }
            else
            {
                $('.editable-error-block').html(response.info);
            }

        },
        error:function(){
            $('.editable-error-block').html('连接失败，请重试！');
        }
    });

})